[#ftl]
[#assign dateJavaTypes = ["Instant", "Date","LocalDateTime","Timestamp"]  /] [#-- JAVA 时间类型 --]
[#assign strJavaTypes = ["String"]  /]  [#--  JAVA字符类型 --]
[#assign numJavaTypes = ["Integer","Long","BigDecimal"]  /]  [#-- JAVA 数值类型 --]
[#assign baseFields = ["versionNum","recToken","updateBy", "updateByName", "updateTime"]  /]  [#-- 基础类字段 --]
[#assign conditionSymbolMap={"eq":"=", "lk":"like","bw":"between","":"="}  
    versionLists=["versionNum", "recToken", "dataStatus","version"] versionUpds=["versionNum", "recToken","version"] /]
[#-- 产生一个序列号 --]
[#function uuidFunc]
[#assign date = .now?string("yyyyMMddHHmmssSSS")][#-- id=.now?long --]
[#return date]
[/#function]

[#-- 后端：方法命名，url拼接--]
[#function MethodNameFunc data_main mdx]
[#return (mdx.methodCode1?cap_first+data_main.moduleKey?cap_first) ]
[/#function]
[#function MethodUrlFunc data_main mdx]
[#return (ControllerUrl(data_main)+mdx.methodUrl) ]
[/#function]
[#function ControllerUrl data_main]
[#return ('/'+data_main.outputModulePath+'/'+data_main.moduleKey+'/') ]
[/#function]
[#function ControllerMethodTitle data_main mdx]
[#return (data_main.moduleKeyName +'-'+ mdx.methodKeyName) ]
[/#function]
[#function ControllerMethodName data_main mdx]
[#return (mdx.methodCode1 + data_main.moduleKey?cap_first) ]
[/#function]
[#function ServiceMethodName data_main mdx]
[#return (MethodNameFunc(data_main,mdx)) ]
[/#function]

[#-- 后台对象字段校验--]
[#macro AnonCheckHandler b]
    [#if b.checkBackground?length>0 ]
    ${b.checkBackground}
    [#else][#if b.mustFlag=="1" && strJavaTypes?seq_contains(b.javaType)]${"\n    "}@NotBlank(message="${b.fieldTitle}不能为空")[#elseif b.mustFlag=="1"]
    @NotNull(message="${b.fieldTitle}不能为空")[/#if][/#if][/#macro]

[#macro AnonCheckHandler2 b]
    [#if b.checkBackground?length>0 ]
    ${b.checkBackground}[#else][#if b.mustFlag=="1" && strJavaTypes?seq_contains(b.javaType)]
    @NotBlank(message = "${b.fieldTitle}不能为空")[#elseif b.mustFlag=="1"]@NotNull(message="${b.fieldTitle}不能为空")[/#if][#if numJavaTypes?seq_contains(b.javaType)]
    @Pattern(regexp = "^\\d+(\\.\\d+){0,1}$",message = "${b.fieldTitle}必须为数值")[/#if][#if dateJavaTypes?seq_contains(b.javaType)]
    @Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$",message = "${b.fieldTitle}不满足时间格式：2022-01-01 10:01:01")[/#if][/#if][/#macro]

[#macro AnonJsonFormat b]
[#if isJavaTypeFunc(b,dateJavaTypes) ]${"\n"}    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")[/#if][/#macro]

[#-- SetterAndGetter--]
[#macro SetterAndGetter entityVO needKeys]
    [#assign flag=true]
    [#if needKeys?? && !(needKeys?is_string) && needKeys?size>0 ]
         [#assign flag=false]    
    [/#if]
    [#list entityVO as b]
    [#if flag || needKeys?seq_contains(b.columnJavaCode) ]
    /**
     * Get${b.columnTitle}
     */
    public ${javaTypeHandlerFunc(b)} get${b.columnJavaCode?cap_first}(){
        return ${b.columnJavaCode};
    }
    /**
     * Set${b.columnTitle}
     */
    public void set${b.columnJavaCode?cap_first}(${javaTypeHandlerFunc(b)} ${b.columnJavaCode}){
        this.${b.columnJavaCode} = ${b.columnJavaCode};
    }
    
    [/#if]
    [/#list]
[/#macro]
[#-- SetterAndGetter2--]
[#macro SetterAndGetter2 entityVO needKeys]
    [#assign flag=true]
    [#if needKeys?? && !(needKeys?is_string) && needKeys?size>0 ]
         [#assign flag=false]    
    [/#if]
    [#list entityVO as b]
    [#if isFieldUseTypeFunc(b,["1","3"]) && (flag || needKeys?seq_contains(b.fieldJavaCode)) ]
    /**
     * Get${b.fieldTitle}
     */
    public ${javaTypeHandlerFunc(b)} get${b.fieldJavaCode?cap_first}(){
        return ${b.fieldJavaCode};
    }
    /**
     * Set${b.fieldTitle}
     */
    public void set${b.fieldJavaCode?cap_first}(${javaTypeHandlerFunc(b)} ${b.fieldJavaCode}){
        this.${b.fieldJavaCode} = ${b.fieldJavaCode};
    }
    
    [/#if]
    [/#list]
[/#macro]


[#-- java类型处理--]
[#function javaTypeHandlerFunc b]
[#if (b.fieldType!'')=="3" ]
[#return "List<"+b.javaType+">"]
[#else]
[#return b.javaType]
[/#if]
[/#function]


[#-- 前端： 方法命名，url拼接 --]
[#function PreIdFunc data_main mdx]
[#return (mdx.methodCode1+'-'+data_main.moduleKey) ]
[/#function]
[#function DlgTitleFunc data_main mdx]
[#return (data_main.moduleKeyName+'-'+mdx.methodKeyName) ]
[/#function]
[#function DlgMethodNameFunc data_main mdx]
[#return (mdx.methodCode1+data_main.moduleKey?cap_first) ]
[/#function]
[#function TableListNameFunc data_main]
[#return data_main.moduleKey+"List" ]
[/#function]

[#-- 权限字符串--]
[#function PermissionFunc data_main key]
[#if data_main.parentModuleKey?length>0]
[#return data_main.parentModuleKey+":"+data_main.moduleKey+":"+key]
[#elseif data_main.outputModulePath?length>0]
[#return data_main.outputModulePath+":"+data_main.moduleKey+":"+key]
[/#if]
[#return data_main.moduleKey+":"+laststr]
[/#function]
[#-- js引入业务方法定义--]
[#macro JsImportMethod data_main data_method]
[#list data_method as mdx][#if mdx.needFlag == '1']${DlgMethodNameFunc(data_main,mdx)}[#if mdx?has_next&&data_method[mdx_index+1].needFlag == '1'],[/#if][/#if][/#list]
[/#macro]
[#-- 是否指定使用类型--]
[#function isFieldUseTypeFunc b currTypes]
[#return currTypes?seq_contains(b.fieldUseType)]
[/#function]
[#-- 是否指定字段类型--]
[#function isJavaTypeFunc b currTypes]
[#return currTypes?seq_contains(b.javaType)]
[/#function]
[#-- 是否指定条件类型--]
[#function isConditionSymbolFunc b currTypes]
[#return currTypes?seq_contains(b.conditionSymbol!"eq")]
[/#function]
[#-- 检查类型--]
[#function checkTypeFunc type="" currTypes=[]]
[#return currTypes?seq_contains(type)]
[/#function]